﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //AjaxPro.Utility.RegisterTypeForAjax(typeof(Index));
        Green.Utility.JQueryAjaxUtility.RegisterClientAjaxScript(typeof(Index));
    }

    //[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
    [Green.Utility.JQueryInvokeMethod()]
    public static string Test(string str)
    {
        //long time = DateTime.Now.Ticks;
        int time = DateTime.Now.Millisecond;
        string appId = "A6916515772039";
        string sha1 = appId + "UZ" + "DEBDA07D-B91A-DB76-EB41-7D4503464688" + "UZ" + time.ToString();
        WebClient client = new WebClient();
        client.Encoding = Encoding.UTF8;
        client.Headers.Add("Content-Type", "application/json");
        client.Headers.Add("X-APICloud-AppId", appId);
        client.Headers.Add("X-APICloud-AppKey", Infrastructure.SHA1Handle.SHA1(sha1).ToLower() + "." + time.ToString());
        var filter = new
        {
            order = "order ASC"
        };
        string url = "https://d.apicloud.com/mcm/api/Html?filter=" + HttpUtility.UrlEncode(filter.ToJson());
        string data = client.DownloadString(url);
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        var obj = serializer.Deserialize<List<Dictionary<string, object>>>(data);
        return obj.ToJson();
    }
}
